package juc.synced;

public class LockTest {
    public static void main(String[] args) throws InterruptedException {
        A a = new A();
        A b = new A();

        long start = System.currentTimeMillis();
        //线程一
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10000000; i++) {
                 a.increase();
            }
        });
        t1.start();


        //线程一
//        Thread t2 = new Thread(() -> {
//            for (int i = 0; i < 10000000; i++) {
//                b.increase();
//            }
//        });
//        t2.start();

        //当前线程
        for (int i = 0; i < 10000000; i++) {
            a.increase();
//            b.increase();
        }
        //等待t1 线程执行完
        t1.join();
//        t2.join();

        //输出结果
        System.out.println("结果a ：" + a.getNum());
//        System.out.println("结果b ：" + b.getNum());
    }
}
